# coding: utf-8
try:
    import re
    import os
    import sys
    import time
    import requests
    import random
    import datetime
    import hashlib
    import socket
except Exception as e:
    t = re.findall("d '(.*?)'", str(e))[0]
    print(f'{t}依赖未安装')
    sys.exit()


"""
cron: 12 */3 * * *
new Env('拾米游')
抓取  https://api.shimiyou.com 的Http-X-Authentication-Token的值
青龙变量 export smytoken="token@赠送游票ID@True"   
第三个参数是开启赠送功能  True为赠送   False为不赠送   多号换行
版本0.4
"""

##################################配置区##################################
text = ''                   # 卡密
# 绑定上级ID  随机绑就多填   不需要1000
def bundled_def():
    bundled_id_new = ['31676', '31689', '31815', '31817', '31818', '32056', '32896', '33151', '33153', '33158', '33160', '33162', '41727']
    return bundled_id_new[random.randint(0, len(bundled_id_new) - 1)]

##################################配置区##################################
#####################################################下面不要动#####################################################
application ='smytoken'#line:3
bundled =True #line:4
token =''#line:5
cumulative_ticket =0 #line:6
host ='https://api.shimiyou.com'#line:7
git ='https://gitee.com'#line:8
url_code ='http://125.91.127.111:1111'#line:9
user ='2313b428183b1a0f5280a7971049b2ce'#line:10
def start ():#line:12
    try :#line:13
        O000OO000O0O00OOO00 ()#line:14
        print (f'你的机器码是：{OO00OO0OO0OO00OO00o0()}')#line:15
        O000OO0O00OO00O00 ()#line:16
        OOOO000O00OO00O0O =os_qinglong ()#line:17
        print (f"==========共找到{len(OOOO000O00OO00O0O)}个账号==========")#line:18
        for O0OO000OOO0O00OOO in OOOO000O00OO00O0O :#line:19
            print (f"------------正在执行第{OOOO000O00OO00O0O.index(O0OO000OOO0O00OOO) + 1}个账号------------")#line:20
            O00OO00OOO0O000OO =SwimUpM (O0OO000OOO0O00OOO )#line:21
            if O00OO00OOO0O000OO .base_info ():#line:23
                if bundled :#line:24
                    O00OO00OOO0O000OO .friend_center ()#line:26
                O00OO00OOO0O000OO .lottery_activities ()#line:28
                O00OO00OOO0O000OO .user_lottery_activity_records ()#line:30
                O00OO00OOO0O000OO .lottery_center_index ()#line:32
                if O00OO00OOO0O000OO .tickets :#line:33
                    O00OO00OOO0O000OO .tickets_give ()#line:35
                time .sleep (random .randint (8 ,15 ))#line:36
            else :#line:37
                print ('token失效')#line:38
        print (f"------------所有账号运行完毕正在统计每天收益------------")#line:39
        print (f'【每天收益】：所有账号累计每天能中:{str(cumulative_ticket)[:6]}张游票')#line:40
    except Exception as O0O000O0O0OO00O0O :#line:41
        print (O0O000O0O0OO00O0O )#line:42
class SwimUpM :#line:44
    def __init__ (O0OO0O0OOO0O000OO ,OOO000OO0O0OOOOO0 ):#line:46
        try :#line:47
            O0OO0O0OOO0O000OO .giving =OOO000OO0O0OOOOO0 .split ("@")[1 ]#line:48
            O0OO0O0OOO0O000OO .tickets =OOO000OO0O0OOOOO0 .split ("@")[2 ]#line:49
            O0OO0O0OOO0O000OO .headers ={'Authorization':'Basic bWlqaWF5b3U6NnpXa3l3ZmtmZ1NyVmNQdQ==','Http-X-Authentication-Token':OOO000OO0O0OOOOO0 .split ("@")[0 ],'user-agent':'Mozilla/5.0 (Linux; Android 12; 2201122C Build/SKQ1.211006.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/95.0.4638.74 Mobile Safari/537.36 uni-app Html5Plus/1.0 (Immersed/30.857143)','Host':'api.shimiyou.com','Cookie':f'AuthenticationToken={OOO000OO0O0OOOOO0.split("@")[0]}',}#line:50
        except Exception as O0OO0OO00O00O0O00 :#line:51
            print ('变量格式错误')#line:52
    def base_info (OO0000OO00O0O0000 ):#line:55
        try :#line:56
            O0OO00OO0O0OOO0OO =requests .request ('get',f'{host}/app_user/v1/users/base_info',headers =OO0000OO00O0O0000 .headers ).json ()#line:57
            if 'code'in O0OO00OO0O0OOO0OO :#line:59
                return False #line:60
            if 'id'in O0OO00OO0O0OOO0OO :#line:61
                O0O000000O000O0OO =O0OO00OO0O0OOO0OO ['nick_name']#line:62
                OOOOO0OO0OO00O00O =O0OO00OO0O0OOO0OO ['card_no']#line:63
                O0000OOOOO0O0O0OO =str (OOOOO0OO0OO00O00O )[4 :5 ]+'**'+str (OOOOO0OO0OO00O00O )[7 :]#line:64
                O00O00OO0O0OOOO00 =O0OO00OO0O0OOO0OO ['ticket']['count']#line:65
                try :#line:66
                    if reversed (O00O00OO0O0OOOO00 )!=0 :#line:67
                        O00O00OO0O0OOOO00 =str (O00O00OO0O0OOOO00 )[:6 ]#line:68
                    else :#line:69
                        O00O00OO0O0OOOO00 =0 #line:70
                except :#line:71
                    O00O00OO0O0OOOO00 =0 #line:72
                print (f'【账号信息】：ID:{O0000OOOOO0O0O0OO}丨昵称:{O0O000000O000O0OO[:7]}丨游票:{O00O00OO0O0OOOO00}')#line:73
            return True #line:86
        except Exception as O0OO00OOO00O0000O :#line:87
            print (O0OO00OOO00O0000O )#line:88
    def friend_center (OOO00OO000O0OO00O ):#line:92
        OOOO0000000O0O0OO =requests .request ('get',f'{host}/app_user/v1/friend_center/index',headers =OOO00OO000O0OO00O .headers ).json ()#line:93
        if 'parent_user'in OOOO0000000O0O0OO :#line:94
            if OOOO0000000O0O0OO ['parent_user']:#line:95
                pass #line:96
            else :#line:97
                O000O0OOO000OOOOO ={"id":bundled_def ()}#line:98
                requests .request ('put',f'{host}/app_user/v1/users/ancestry',headers =OOO00OO000O0OO00O .headers ,data =O000O0OOO000OOOOO ).json ()#line:99
    def user_lottery_activity_records (O00OO0O0O0000O0OO ):#line:102
        global cumulative_ticket #line:103
        OOO0O00OOO00O000O =0 #line:104
        O0O0000OO00O00000 =0 #line:105
        try :#line:106
            O0OOOO00O00000O00 =requests .request ('get',f'{host}/app_user/v1/users/user_lottery_activity_records?page=1&per_page=20',headers =O00OO0O0O0000O0OO .headers ).json ()#line:107
            if 'user_lottery_activity_records'in O0OOOO00O00000O00 :#line:108
                for O0OOO0O00OOO0OO0O in O0OOOO00O00000O00 ['user_lottery_activity_records']:#line:109
                    if '7a468d93-aa43-4131-b414-b828b985e97e'==O0OOO0O00OOO0OO0O ['lottery_activity_id']:#line:110
                        OOO0O00OOO00O000O =O0OOO0O00OOO0OO0O ['bet_on']#line:111
                    if '94437862-d71c-4ff9-b2ff-343b094acd0d'==O0OOO0O00OOO0OO0O ['lottery_activity_id']:#line:112
                        O0O0000OO00O00000 =O0OOO0O00OOO0OO0O ['bet_on']#line:113
                print (f'【参与抽奖】：普通奖券:{O0O0000OO00O00000}张丨高级奖券:{OOO0O00OOO00O000O}张')#line:114
            if 'lottery_activity'in O0OOOO00O00000O00 :#line:115
                for O0OOO0O00OOO0OO0O in O0OOOO00O00000O00 ['lottery_activity']:#line:116
                    if O0OOO0O00OOO0OO0O ['topic']=='普通奖券抽游票':#line:117
                        O00OO00OO0OOO00OO =O0OOO0O00OOO0OO0O ['sum_bet_on']#line:118
                        OOO0O00000O000OOO =2880 *34 /O00OO00OO0OOO00OO *O0O0000OO00O00000 #line:119
                        cumulative_ticket +=OOO0O00000O000OOO #line:120
                        print (f'【参与抽奖】：普通奖券预计每天能中:{str(OOO0O00000O000OOO)[:5]}')#line:121
                    if O0OOO0O00OOO0OO0O ['topic']=='高级奖券抽游票':#line:122
                        O00OO00OO0OOO00OO =O0OOO0O00OOO0OO0O ['sum_bet_on']#line:123
                        OOO0O00000O000OOO =2880 *313 /O00OO00OO0OOO00OO *OOO0O00OOO00O000O #line:124
                        cumulative_ticket +=OOO0O00000O000OOO #line:125
                        print (f'【参与抽奖】：高级奖券预计每天能中:{str(OOO0O00000O000OOO)[:5]}')#line:126
        except Exception as O0OO0O0O0000O00O0 :#line:128
            print (O0OO0O0O0000O00O0 )#line:129
    def tickets_give (O0OOO0000OO0OO0OO ):#line:133
        try :#line:134
            OO0OOO0O0O00O000O =requests .request ('get',f'{host}/app_user/v1/users/base_info',headers =O0OOO0000OO0OO0OO .headers ).json ()#line:135
            OO0O0O0000O00O00O =str (OO0OOO0O0O00O000O ['card_no'])[4 :]#line:136
            if O0OOO0000OO0OO0OO .giving !=OO0O0O0000O00O00O :#line:137
                OO0O00000O0O000O0 =OO0OOO0O0O00O000O ['ticket']['count']#line:138
                if float (OO0O00000O0O000O0 )==0 :#line:139
                    print ('【赠送游票】：账号初始化中')#line:140
                    return True #line:141
                OO0O0O00OOO00OO00 =str (OO0O00000O0O000O0 ).split ('.')[0 ]#line:142
                OOO0000O0O000000O =int (str ((float (OO0O0O00OOO00OO00 )/1.1 )/10 ).split (".")[0 ])*10 #line:143
                if int (OO0O0O00OOO00OO00 )>10 :#line:144
                    O0O000O000O00O0OO ={"id":O0OOO0000OO0OO0OO .giving ,"count":OOO0000O0O000000O }#line:145
                    OOO00O000O0OOOOOO =requests .put (f'{host}/app_user/v1/ticket_record/tickets_give',headers =O0OOO0000OO0OO0OO .headers ,data =O0O000O000O00O0OO ).json ()#line:146
                    if 'count'in OOO00O000O0OOOOOO :#line:147
                        print (f'【赠送游票】：赠送{OOO0000O0O000000O}张游票给{O0OOO0000OO0OO0OO.giving}成功丨余额{str(OOO00O000O0OOOOOO["count"])[:5]}')#line:148
                    else :#line:149
                        print ('【赠送游票】：失败')#line:150
                else :#line:151
                    print ('【赠送游票】：余额不足不执行操作')#line:152
            else :#line:153
                print ('【赠送游票】：赠送的ID是自己不执行操作')#line:154
        except Exception as O0O0O0000OOO0OOOO :#line:155
            print (O0O0O0000OOO0OOOO )#line:156
    def lottery_activities (OO00O0OO000OO000O ):#line:160
        try :#line:161
            O0000OOOO0O000O0O =requests .request ('get',f'{host}/app_user/v1/lottery_activities/lt_type/lottery/info',headers =OO00O0OO000OO000O .headers ).json ()#line:162
            if 'count'in O0000OOOO0O000O0O :#line:164
                OO0OO000OOOO0OOO0 =O0000OOOO0O000O0O ['count']#line:165
                print (f'【转盘抽奖】：剩余{OO0OO000OOOO0OOO0}次抽奖')#line:166
                if OO0OO000OOOO0OOO0 >0 :#line:167
                    for OO0O0OOOOOO0OO0OO in range (OO0OO000OOOO0OOO0 ):#line:168
                        OO0OO00000O00O00O =requests .request ('post',f'{host}/app_user/v1/lottery_activities/lt_type/lottery/info',headers =OO00O0OO000OO000O .headers ).json ()#line:169
                        if 'name'in OO0OO00000O00O00O :#line:170
                            print (f'【转盘抽奖】：获得:{OO0OO00000O00O00O["name"]}{OO0OO00000O00O00O["prize_number"]}张')#line:171
                        time .sleep (random .randint (15 ,30 )/10 )#line:172
        except Exception as OO0OO0000000O0O00 :#line:173
            print (OO0OO0000000O0O00 )#line:174
    def lottery_center_index (O0OOOOOOO000O0000 ):#line:178
        try :#line:179
            O00OOOOOOOOO00000 =requests .request ('get',f'{host}/app_user/v1/lottery_center/index?page=1&per_page=20',headers =O0OOOOOOO000O0000 .headers ).json ()#line:180
            if 'tickets'in O00OOOOOOOOO00000 :#line:181
                for OO00O0O000000OO0O in O00OOOOOOOOO00000 ['tickets']:#line:182
                    if OO00O0O000000OO0O ['name']=='游票':#line:183
                        print (f'【抽奖累计】：累计中了{str(OO00O0O000000OO0O["total_count"])[:6]}张游票')#line:184
            if 'cumulative_tickets'in O00OOOOOOOOO00000 :#line:185
                if O00OOOOOOOOO00000 ['tickets']:#line:186
                    for OO00O0O000000OO0O in O00OOOOOOOOO00000 ['tickets']:#line:187
                        O0OO000O0O0O0OOOO =OO00O0O000000OO0O ['count']#line:188
                        OO00OO000O0OOOO0O =OO00O0O000000OO0O ['lt_type']#line:189
                        if OO00OO000O0OOOO0O =='normal':#line:190
                            O0000OOOOOO0OO0OO ='94437862-d71c-4ff9-b2ff-343b094acd0d'#line:191
                            if O0OO000O0O0O0OOOO >'1':#line:192
                                O0OOOOOOO000O0000 .add_lottery_ticket (O0OO000O0O0O0OOOO ,O0000OOOOOO0OO0OO )#line:193
                                time .sleep (2 )#line:194
                        if OO00OO000O0OOOO0O =='advanced':#line:195
                            O0000OOOOOO0OO0OO ='7a468d93-aa43-4131-b414-b828b985e97e'#line:196
                            if O0OO000O0O0O0OOOO >'1':#line:197
                                O0OOOOOOO000O0000 .add_lottery_ticket (O0OO000O0O0O0OOOO ,O0000OOOOOO0OO0OO )#line:198
        except Exception as OOOOOOOOO0OOOOO0O :#line:199
            print (OOOOOOOOO0OOOOO0O )#line:200
    def add_lottery_ticket (OOOO0O0O000O0OO0O ,OO0OOO00OO0OO0OO0 ,O0OO0OOO0000OOO00 ):#line:204
        try :#line:205
            OOO0O00OO0000OOO0 ={"bet_on":OO0OOO00OO0OO0OO0 .split ('.')[0 ],"operation":"in","lotteru_activity_id":O0OO0OOO0000OOO00 }#line:206
            O0OOOOO0OOO00O0O0 =requests .request ('post',f'{host}/app_user/v1/lottery_center/activities',headers =OOOO0O0O000O0OO0O .headers ,data =OOO0O00OO0000OOO0 ).json ()#line:207
            if 'bet_on'in O0OOOOO0OOO00O0O0 :#line:208
                print (f'【添加奖券】：添加{OO0OOO00OO0OO0OO0.split(".")[0]}张成功')#line:209
        except Exception as OO0O00O000O0O0OO0 :#line:210
            print (OO0O00O000O0O0OO0 )#line:211
def version_of_the_validation ():#line:215
    return str ((57 -56 )/10 )#line:216
def alal ():#line:218
    return 'vasttttt/hairy/raw/master'#line:219
def gitee_edition ():#line:221
    try :#line:222
        return requests .get (f'{git}/{alal()}/edition').json ()#line:223
    except :#line:224
        sys .exit (0 )#line:225
def ubbbf ():#line:226
    print ('卡密验证通过   ✅')#line:227
def oyoy ():#line:228
    return '卡密未激活   ❌'#line:229
edition =gitee_edition ()#line:232
def get_ip ():#line:233
    return re .findall ('ip: (.*) ',requests .request ('get','https://dev.kdlapi.com/testproxy',headers ={"Accept-Encoding":"Gzip"}).text )[0 ]#line:234
def OO00OO0OO0OO00OO00o0 ():#line:236
    return hashlib .md5 ((socket .gethostbyname (get_ip ())+socket .getfqdn (socket .gethostname ())+'10086').encode ('utf-8')).hexdigest ().upper ()#line:237
def O000OO0O00OO00O00 ():#line:238
    O0O00000O0O0O0OO0 ={'user':user ,'text':text ,'Carmi':OO00OO0OO0OO00OO00o0 ()}#line:239
    OOOOO000OO00O0O0O =requests .request ('post',f'{url_code}/configure',data =O0O00000O0O0O0OO0 ).json ()#line:240
    if 'code'in OOOOO000OO00O0O0O :#line:241
        if OOOOO000OO00O0O0O ['code']==200 :#line:242
            if OOOOO000OO00O0O0O ['data']['conf']:#line:243
                ubbbf ()#line:244
            else :#line:245
                print (oyoy ())#line:246
                exit (3 )#line:247
        else :#line:248
            print ('开始绑定激活卡密')#line:249
            O0OO00OO0O000O00O =requests .request ('post',f'{url_code}/validation',data =O0O00000O0O0O0OO0 ).json ()#line:250
            if 'code'in O0OO00OO0O000O00O :#line:251
                if O0OO00OO0O000O00O ['code']==200 :#line:252
                    print (O0OO00OO0O000O00O ['data']['msg'])#line:253
            print (oyoy ())#line:254
            exit (2 )#line:255
    else :#line:256
        print (oyoy ())#line:258
        exit (1 )#line:259
def O000OO000O0O00OOO00 ():#line:263
    try :#line:264
        if version_of_the_validation ()<edition ['SwimUpM']['edition']:#line:265
            print (f'当前脚本名字: {edition["SwimUpM"]["text"]}')#line:266
            print (f'当前版本=>> {version_of_the_validation()}'+f'丨远程版本=>> {edition["SwimUpM"]["edition"]} 请及时更新至最新版  ❌')#line:267
            print (f'更新内容=>> {edition["SwimUpM"]["content"]}')#line:268
        else :#line:269
            print (f'当前脚本名字: {edition["SwimUpM"]["text"]}')#line:270
            print (f'当前版本=>> {version_of_the_validation()}'+f'丨远程版本=>> {edition["SwimUpM"]["edition"]}   ✅')#line:271
            print (f'更新内容=>> {edition["SwimUpM"]["content"]}')#line:272
    except Exception as O00O0OOOO00OO000O :#line:273
        print (O00O0OOOO00OO000O )#line:274
def os_qinglong ():#line:277
    if application in os .environ :#line:278
        O00OOO00OO00OOO0O =os .environ [application ].split ('\n')#line:279
        if len (O00OOO00OO00OOO0O )>0 :#line:280
            return O00OOO00OO00OOO0O #line:281
        else :#line:282
            print (f"{application}变量未启用")#line:283
            print ('脚本退出')#line:284
            sys .exit (1 )#line:285
    else :#line:286
        print (f"{application}变量为空\n尝试使用内置变量")#line:287
        return os_built ()#line:288
def os_built ():#line:291
    if token :#line:292
        O0OO0000OO0000000 =token .split ('\n')#line:293
        if len (O0OO0000OO0000000 )>0 :#line:294
            return O0OO0000OO0000000 #line:295
    else :#line:296
        print (f"内置变量为空")#line:297
        print ('脚本退出')#line:298
        sys .exit (0 )#line:299
if __name__ =='__main__':#line:302
    start ()#line:303
